package org.come.Jpanel;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.LotteryNineBtn;
import com.tool.btn.RoleOperationPanelBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;
import org.come.mouslisten.GoodsMouslisten;
import org.come.mouslisten.LotteryGoodslisten;
import org.come.until.CutButtonImage;
import org.come.until.LotteryFromServerUntil;

import javax.swing.*;
import java.awt.*;

public class FanfanleJpanel extends JPanel {

    private LotteryNineBtn btnReset,drop;

    private JLabel[] GoodsListLabel;

    private LotteryGoodslisten[] goodsMouslistens;

    public FanfanleJpanel() throws Exception {
        this.setPreferredSize(new Dimension(358, 329));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);

        this.GoodsListLabel = new JLabel[9];
        this.goodsMouslistens = new LotteryGoodslisten[9];

        int Flag = 0, count = 1;// 用来标记行和列
        for (int i = 0; i < 9; i++) {
            GoodsListLabel[i] = new JLabel();
            //GoodsListLabel[i].setIcon(CutButtonImage.getImage("img/item/FFBG00.png", -1, -1));
            goodsMouslistens[i] = new LotteryGoodslisten(i);
            GoodsListLabel[i].addMouseListener(goodsMouslistens[i]);

            if ((Flag < 3) && (count == 1)) {
                GoodsListLabel[i].setBounds(58 + Flag * 82, 55, 60, 60);
                Flag++;// 用来标记行
                this.add(GoodsListLabel[i]);
            }
            if ((Flag < 3) && (count == 2)) {
                GoodsListLabel[i].setBounds(58 + Flag * 82, 135, 60, 60);
                Flag++;// 用来标记行
                this.add(GoodsListLabel[i]);
            }
            if ((Flag < 3) && (count == 3)) {
                GoodsListLabel[i].setBounds(58 + Flag * 82, 215, 60, 60);
                Flag++;// 用来标记行
                this.add(GoodsListLabel[i]);
            } else if (Flag == 3) {
                Flag = 0;
                count++;
            }
        }

        if(MyIsif.getStyle().equals("水墨UI")) {
//            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/button/1.png", 1, 999);
//            offBtn.setBounds(358 - 37, 10, 25, 25);
////            this.add(offBtn);

            btnReset = new LotteryNineBtn("inkImg/newbutton/B32.png", 1, "洗牌", this);
            btnReset.setBounds(48, 280, 51, 30);
            this.add(btnReset);

            drop = new LotteryNineBtn("inkImg/newbutton/B30.png", 1, "放弃", this);
            drop.setBounds(240, 18, 51, 17);
            this.add(drop);

         }else {
//            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/button/1.png", 1, 999);
//            offBtn.setBounds(358 - 37, 10, 25, 25);
////            this.add(offBtn);

            btnReset = new LotteryNineBtn("inkImg/hongmu/B32h.png", 1, "洗牌", this);
            btnReset.setBounds(80, 288, 51, 17);
            this.add(btnReset);

            drop = new LotteryNineBtn("inkImg/hongmu/B32h.png", 1, "放弃", this);
            drop.setBounds(180, 288, 51, 17);
            this.add(drop);
        }
    }

    private ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (MyIsif.getStyle().equals("水墨UI")) {
            icon = new ImageIcon("inkImg/newbackground/B462.png");
            g.drawImage(icon.getImage(), 0, 0, 311, 325, this);
            LotteryFromServerUntil.draw(g, 60, 50);
        } else {
            icon = new ImageIcon("inkImg/newbackground/B462-1.png");
            g.drawImage(icon.getImage(), 0, 0, 311, 325, this);
            LotteryFromServerUntil.draw(g, 60, 50);
        }
    }
}
